package com.tian.controller;

import com.github.pagehelper.PageInfo;
import com.tian.pojo.Anime;
import com.tian.pojo.Beauty;
import com.tian.pojo.Scenery;
import com.tian.service.AnimeService;
import com.tian.service.BeautyService;
import com.tian.service.SceneryService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import org.springframework.ui.Model;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestParam;

import java.util.List;

@Controller
@RequestMapping("/admin")
public class AdminController {
    @Autowired
    private SceneryService sceneryService;
    @Autowired
    private BeautyService beautyService;
    @Autowired
    private AnimeService animeService;
    @RequestMapping("/toScenery")
    public String toScenery(){
        return "scenery";
    }
    @RequestMapping("/getScenery")
    public String getScenery(Model model, @RequestParam(defaultValue = "1")Integer pageNum, @RequestParam(defaultValue = "12") Integer size){
        List<Scenery> list=sceneryService.getAllScenery(pageNum,size);
        PageInfo pageInfo=new PageInfo(list);
        model.addAttribute("pageInfo",pageInfo);
        return "admin/scenery";
    }
    @RequestMapping("/getBeauty")
    public String getBeauty(Model model, @RequestParam(defaultValue = "1")Integer pageNum, @RequestParam(defaultValue = "12") Integer size){
        List<Beauty> list=beautyService.getAllBeauty(pageNum,size);
        PageInfo pageInfo=new PageInfo(list);
        model.addAttribute("pageInfo",pageInfo);
        return "admin/beauty";
    }
    @RequestMapping("/getAnime")
    public String getAnime(Model model, @RequestParam(defaultValue = "1")Integer pageNum, @RequestParam(defaultValue = "12") Integer size){
        List<Anime> list=animeService.getAllAnime(pageNum,size);
        PageInfo pageInfo=new PageInfo(list);
        model.addAttribute("pageInfo",pageInfo);
        return "admin/anime";
    }
}
